<?php

namespace app\admin\controller\course;

use app\admin\controller\AuthController;
use app\admin\model\course\CourseGroup as CourseGroupModel;
use services\JsonService;
use services\UtilService as Util;

/**
 * 课程的分类
 * Class CourseCategory
 * @package app\admin\controller\course
 */
class CourseGroup extends AuthController
{
    /**
     * 显示资源列表
     * @return string
     * @throws \think\db\exception\DataNotFoundException
     * @throws \think\db\exception\DbException
     * @throws \think\db\exception\ModelNotFoundException
     */
    public function index()
    {
        $this->assign('group', CourseGroupModel::getTierList(null));
        return $this->fetch();
    }

    /**
     * @title 获取所有的分组的列表
     */
    public function course_group()
    {
        $where = Util::getMore([
            ['is_show', ''],
            ['group_name', ''],
            ['page', 1],
            ['limit', 20],
            ['order', '']
        ]);
        return JsonService::successlayui(CourseGroupModel::groupList($where));
    }
}